#include <iostream>
#include "tunnelconstructor.h"
#include <fstream>

#include "http/httpserver.h"
#include "htmldata.h"

void usage(char* argv0)
{
    std::cout << "Usage:" << std::endl;
    std::cout << argv0 << " <bind address> <bind port>" << std::endl;
}

int main(int argc, char* argv[])
{
    if (argc < 3)
    {
        usage(argv[0]);
        return 0;
    }

    const std::string address (argv[1]);
    const uint16_t port (std::stoi(argv[2]));

    std::cout << "Address: http://" << address << ":" << port << std::endl;

    crow::App<crow::UTF8> app;
    app.loglevel(crow::LogLevel::Critical);

    HttpServer server(address, port);
    try {
        server.run();
    } catch (std::exception& e) {
        std::cerr << "Server failure: " << e.what() << std::endl;
        return 1;
    }

    return 0;
}
